package api

// Response 标准API响应结构
type Response struct {
	Code    string      `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

// PaginatedResponse 分页响应结构
type PaginatedResponse struct {
	Data       interface{} `json:"data"`
	Total      int64       `json:"total"`
	Page       int         `json:"page"`
	PageSize   int         `json:"page_size"`
	TotalPages int64       `json:"total_pages"`
}

// SuccessResponse 成功响应
func SuccessResponse(data interface{}) Response {
	return Response{
		Code:    "SUCCESS",
		Message: "Operation successful",
		Data:    data,
	}
}

// ErrorResponse 错误响应
func ErrorResponse(message string) Response {
	return Response{
		Code:    "ERROR",
		Message: message,
	}
}

// PaginatedSuccessResponse 分页成功响应
func PaginatedSuccessResponse(data interface{}, total int64, page, pageSize int) PaginatedResponse {
	totalPages := (total + int64(pageSize) - 1) / int64(pageSize)
	return PaginatedResponse{
		Data:       data,
		Total:      total,
		Page:       page,
		PageSize:   pageSize,
		TotalPages: totalPages,
	}
}